/*
 * networkedLocksTestThree.c
 *
 *  Created on: Jul 12, 2011
 *      Author: peckb1
 */

#include "syscall.h"

int sharedLockIdTwo = -1;
int sharedCVIdTwo   = -1;


void LockWaitHappyCaseBroadcaster() {
    CVBroadcast(sharedCVIdTwo, sharedLockIdTwo);

    Exit(0);
}

void LockWaitHappyCaseWaiterForBroadcast() {
    LockAcquire(sharedLockIdTwo);

    Fork(&LockWaitHappyCaseBroadcaster, "Broadcaster", 11);

    CVWait(sharedCVIdTwo, sharedLockIdTwo);

    LockRelease(sharedLockIdTwo);

    LockDestroy(sharedLockIdTwo);

    CVDestroy(sharedCVIdTwo);

    Exit(0);
}

int main() {

    sharedLockIdTwo = CreateLock("Shared Lock Two", 15);
    sharedCVIdTwo   = CreateCV("Shared CV Two", 13);
    Fork(&LockWaitHappyCaseWaiterForBroadcast,   "BroadcastWaiter", 16);

    Exit(0);

}
